import 'package:flutter/material.dart';
import 'package:getx_scaffold/getx_scaffold.dart';
import 'package:oramemo/common/res/gaps.dart';
import 'package:oramemo/common/langs/text_key.dart';

import '../transcription_recode_logic.dart';
import '../widgets/player_widget.dart';

class UploadView extends StatelessWidget {
  const UploadView({
    super.key,
  });

  @override
  Widget build(BuildContext context) {
    return GetBuilder<TranscriptionRecodeLogic>(builder: (logic) {
      return Container(
        margin: const EdgeInsets.only(top: 46, left: 22, right: 22),
        padding: const EdgeInsets.only(
            top: 20, left: 14, right: 14, bottom: 20),
        decoration: BoxDecoration(
            color: Colors.white, borderRadius: BorderRadius.circular(12)),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            PlayerWidget(
              onTap: () {
                logic.playPause();
              },
              isPlaying: logic.isPlaying,
              position: logic.position,
              duration: logic.duration,
            ),
            Gaps.vGap32,
            Row(
              mainAxisSize: MainAxisSize.max,
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                ButtonX.primary(
                  TextKey.uploadConfirm.tr,
                  minSize: Size(137.w, 50),
                  onPressed: () {
                    logic.uploadFile();
                  },
                ),
                ButtonX.outline(
                  TextKey.uploadReRecord.tr,
                  minSize: Size(137.w, 50),
                  onPressed: () {
                    logic.recordedFilePath = null;
                    logic.update();
                  },
                ),
              ],
            ),
          ],
        ),
      );
    });
  }
}
